﻿/**
 * Copyright © TnT-VNGroup 2011
 * PROJECT:   SmartCollector
 * $HeadURL: http://smartcollector.googlecode.com/svn/branches/Srcs/SmartCollector.HtmlParser/Utilities/TagFactory.cs $
 * $Author: chithanh12@gmail.com $
 * $Date: 2011-05-04 09:28:35 +0000 (Wed, 04 May 2011) $
 * $Rev: 112 $
 **/
using System.Collections.Generic;
namespace HtmlParser
{
    public class TagFactory
    {
        

        /// <summary>
        /// Creates the HTML tag.
        /// </summary>
        /// <returns></returns>
        public static HtmlTag CreateHtmlTag(string tagName, List<Attribute> attributes, TagType isEndTag)
        {
           // string htmlTagType = TagHelper.ParseTagType(tagName);
            HtmlTag result = null;
            switch (tagName.ToUpperCamel())
            {
                case HtmlTags.IMG:
                    result = new ImgTag();
                    isEndTag = TagType.OpenClose;
                    break;
                case HtmlTags.A:
                    result = new AnchorTag();
                    break;
                case HtmlTags.BR:
                    isEndTag = TagType.OpenClose;
                    result = new HtmlTag();
                    break;
                //TODO: Some Embed tab is not work.Plz check it after
                case HtmlTags.EMBED:
                    result = new Embed();
                    break;
                default:
                    result = new HtmlTag();
                    result.IsEndTag = isEndTag;
                    break;
            }

            result.TagName = tagName;
            result.AddAttribute(attributes);
            result.IsEndTag = isEndTag;
            return result;
        }
    }
}
